<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let s = 'pwwkew'
        const set = new Set();
        let i = 0, j = 0, maxsetlength = 0;
        if (s.length == 0) {
            console.log(0);
        }
        for (i; i < s.length; i++) {
            if (!set.has(s[i])) {
                set.add(s[i]);
                console.log(set);
                maxsetlength = Math.max(maxsetlength, set.size);
            } else {
                console.log('2');
                console.log(s[i]);
                console.log(set.has(s[i]));
                while (set.has(s[i])) {
                    console.log('3');
                    set.delete(s[j]);
                    console.log(set);
                    j++;
                }
                set.add(s[i]);

            }
        }
        console.log(set);
    </script>
</body>

</html>